﻿using Microsoft.AspNetCore.Mvc.Filters;
using NLog;

namespace Apps.WebApi.Filter
{
    public class CustomActionFilter : ActionFilterAttribute
    {
        private static readonly NLog.ILogger _logger = LogManager.GetCurrentClassLogger();

        public override void OnActionExecuting(ActionExecutingContext context)
        {
            // 在动作执行之前执行的逻辑
            _logger.Info("OnActionExecuting: Action is about to execute.");
            base.OnActionExecuting(context);
        }

        public override void OnActionExecuted(ActionExecutedContext context)
        {
            // 在动作执行之后执行的逻辑
            _logger.Info("OnActionExecuted: Action has executed.");
            base.OnActionExecuted(context);
        }
    }
}
